$(function () {
    var userId = config.getUserId();

    $.get(config.baseUrl + "/account/quaryAccount.json",{userId: userId}, function(result){
        if (result.status == 200) {
            var html = template("select-account-temp", result);
            $("#account-zhuanrujiaoyi").html(html);
        }
    });
    template.defaults.imports.accountTypeName = function(value){
        return config.accountType(value);
    };

})

function save(){
    var payPassword = $("#payPassword").val();
    var param = {
        userId:config.getUserId(),
        chargeAccount:$("#account-zhuanrujiaoyi").val(),
        amountNum:$("#amountNum").val()
    }
    // ��֤֧������
    $.get(config.baseUrl+"/user/validatorPayPassword.json", {userId:userId, payPassword: payPassword}, function(result){
        if(result.status == 200) {
            $.post(config.baseUrl+"/account/profitsToCapital.json",param, function(result){
                if(result.status == 200) {
                    layer.alert("ת�سɹ�");
                    $("#sub").reset();
                } else {
                    layer.alert(result.msg);
                }
            },"json");
        } else {
            layer.alert("֧���������");
        }
    }, "json")

    return false;
}